<?php

declare(strict_types=1);

namespace app\model\admin;

use app\model\AdminBaseModel;
use think\Model;

/**
 * @mixin \think\Model
 */
class ProductAttrResult extends AdminBaseModel
{
    // 数据表名称
    // 产品规格名和产品规格值
    protected $table = 'product_attr_result';
    protected $scopeField = true;

    //可搜索字段
    protected $searchField = [];
    // like
    protected $singleSearchField = [];
    //可作为条件的字段
    protected $whereField = ['product_id'];
    //可做为时间范围查询的字段
    protected $timeField = ['created_at'];

    public function setResultAttr($value)
    {
        if ($value && is_array($value)) {
            // var_dump($value);
            $this->set('result', json_encode($value));
        }
    }
    public function getResultAttr($value, $data)
    {
        if (isset($data['result'])) {
            // var_dump($value);
            return json_decode($value, true);
        }
    }
}
